<template>
  <div class="wapper">
    <el-container style="100%">
      <el-main style="background:#fff;">
        <div class="table-wrap" v-show="listShow">
          <div class="handle-box3">
            <el-form :inline="true" ref="form" :model="searchForm" class="demo-form-inline">
              <div class="uers-left">
                <el-form-item label="搜索：">
                  <el-input v-model="searchForm.name" placeholder="名称"></el-input>
                </el-form-item>
                 <el-form-item label="">
                  <el-input v-model="searchForm.phone" placeholder="手机"></el-input>
                </el-form-item>
                <el-form-item label="证件类型：">
                  <el-select v-model="searchForm.documentTypeId" placeholder="选择证件类型">
                    <el-option
                      v-for="(type,index) in DocumentType"
                      :label="type.name"
                      :key="index"
                      :value="type.documentTypeId">
                      <div @click="getChangeType(type)">{{type.name}}</div>
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="searchSubmit()">搜索</el-button>
              </div>
            </el-form>
          </div>
          <div class="tabbox">
          <el-table
            :data="dataList"
            height="100%"
            border
            class="tabbox"
            ref="multipleTable"
            :header-cell-style="{background:'#f2f6fc',color:'#606266'}"
            @selection-change="handleSelectionChange"
          >
            <el-table-column type="selection" width="55" align="center"></el-table-column>
            <el-table-column prop="name" label="姓名" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.name}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="phone" label="手机" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.phone}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="typeName" label="证件类型" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.typeName}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="number" label="新增数量" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.number}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="url" label="备注" width="400" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.url}}</span>
              </template>
            </el-table-column>
            <el-table-column prop="createDate" label="创建时间" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.createDate}}</span>
              </template>
            </el-table-column>
          </el-table></div>
          <div class="fb"><el-pagination
            class="pag"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pagesize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
          ></el-pagination></div>
        </div>
      </el-main>
    </el-container>
  </div>
</template>
<script>

export default {
  data() {
    return {
      total: 0, //总条数
      currentPage: 1, //初始页
      pagesize: 10, // 每页的数据
      //表格高度适配
      tabheight: "",
      searchForm: {
        name: "",
        phone: "",
        documentTypeId:''
      },
      editData: {},
      listShow: true,
      editShow: false,
      dataList: [],
      multipleSelection: [],
      DocumentType:[],
      projectId:localStorage.getItem('project_Id')
    };
  },
  mounted() {
    // this.tabheight=(this.$refs.getheight.offsetHeight-165)
  },
  created() {
    this.getData();
    this.getDocumentType();
  },
  methods: {
    handleSizeChange(val) {
      this.pagesize = val;
      this.getData();
    },
    handleCurrentChange(val) {
      this.currentPage = val;
      this.getData();
    },
    searchSubmit() {
      this.currentPage=1;
      this.getData();
    },
    // 获取数据
    getData() {
      var search = {
        name: this.searchForm.name,
        pageIndex: this.currentPage - 1,
        pageSize: this.pagesize,
        documentTypeId: this.searchForm.documentTypeId==""?0:this.searchForm.documentTypeId,
        phone: this.searchForm.phone,
        projectId:this.projectId,
        type:1,
      }
      this.$axios.post('/DocumentRecord/Search',search).then(res =>{
        if (res.data.hasError == false) {
          this.dataList = [...res.data.data]
          this.total = res.data.total
        }
      })
    },
    getDocumentType(){
      this.$axios.get('/DocumentType/Project/'+this.projectId).then(res =>{
        if (res.data.hasError == false) {
          this.DocumentType = [...res.data.data]
        }
      })
    },
    getChangeType(type){
      this.searchForm.documentTypeId = type.documentTypeId;
    },
    handleSelectionChange(val) {
      this.multipleSelection = val;
    },
    getFunStu() {
      this.listShow = true;
      this.editShow = false;
      this.getData();
    }
  }
};
</script>
<style lang="scss" scope>
.pag {
  position: absolute;
  bottom: 0;
}

.table-wrap {
  margin-left: 10px;
  height: 100%;
}
.el-main{
  border-radius: 5px;
  position: relative;
}
.uers-left {
  float: left;
}
.uers-right {
  float: right;
}
.el-dialog{height: auto;}
.tabbox{
  height: calc(100% - 100px);
}
</style>